  class Es5AopShopping {

    /**
     * 添加商品到购物车 
     */
    _doAddToCard() {
        // 添加商品到购物车的主要逻辑
    }

    /**
     * 结算
     */
    _doCheckout() {
          // 结算购物车的主要逻辑
    }


    addToCart(item:string) {
        this._doAddToCard();
    }

    checkout() {
        this._doCheckout();
    }
}

function logBeforex(targetFn:(args) => void) {
    return function (...args:any) {
      console.log(`调用函数 ${targetFn.name}，参数为 ${args}`);
      return targetFn.apply(this, args);
    };
  }

const shopping = new Es5AopShopping();
const addToCartWithLog = logBeforex(shopping.addToCart.bind(shopping));
const checkoutWithLog = logBeforex(shopping.checkout.bind(shopping));


addToCartWithLog("商品A")
addToCartWithLog("商品B")
addToCartWithLog("商品C")
checkoutWithLog()
